Skip to content

fix(browser): recover stale CDP sessions#112

Open
MagMueller wants to merge 4 commits into
mainfrom
session-recovery
Open

fix(browser): recover stale CDP sessions#112
MagMueller wants to merge 4 commits into
mainfrom
session-recovery

Conversation

@MagMueller

@MagMueller MagMueller commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • keep the current CDP socket active until a replacement WebSocket has actually opened, and scope pending calls to the socket that owns them
  • on Chrome’s explicit Session with given id not found rejection, perform one serialized reattach to a usable page (or create about:blank) and retry once
  • restore Page, DOM, Runtime, and Network subscriptions on the replacement session so event-driven code keeps working
  • deliberately do not replay commands after an ambiguous socket drop, where Chrome may already have applied the action
  • cover concurrent stale-session failures, empty/internal target lists, dropped sockets, failed replacement connections, late closes from replaced sockets, and domain restoration

This ports the narrow, deterministic session-recovery behavior from the public browser-harness daemon while keeping transport-drop recovery conservative.

Validation

  • bun test in packages/bcode-browser: 18 pass, 8 environment-gated skips
  • bun typecheck in packages/bcode-browser
  • root filtered typecheck: 13/13 packages pass
  • bunx oxlint packages/bcode-browser/test/cdp-recovery.test.ts: clean
  • recovery test file repeated 10 times without failure

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/bcode-browser/src/cdp/session.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/bcode-browser/src/cdp/session.ts Outdated
Comment thread packages/bcode-browser/src/cdp/session.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant